package cn.kaguyaever.service.impl;

import cn.kaguyaever.dao.JudgeDao;
import cn.kaguyaever.dao.impl.JudgeDaoImpl;
import cn.kaguyaever.entity.Judge;
import cn.kaguyaever.service.JudgeService;

import java.util.List;

public class JudgeServiceImpl implements JudgeService {

    private JudgeDao judgeDao = new JudgeDaoImpl();

    public void createJudge(Judge judge){
        judgeDao.createJudge(judge);
    }

    public Judge judgeLogin(Judge judge){
        return judgeDao.queryJudgeByJudgenameAndPassword(judge.getJudgename(),judge.getJudgepassword(),judge.getProjectId());
    }

    public boolean judgeStatus(Integer judgeId){
        return judgeDao.queryJudgeByJudgeId(judgeId).getStatus() != 1;
    }

    public List<Judge> queryJudge(String projectId){return judgeDao.queryAllJudgeByProjectId(projectId);}

    public boolean existJudge(String name,String projectId){
        return judgeDao.queryJudgeByJudgename(name, projectId) != null;
    }

    public void setStatus(Integer judgeId){judgeDao.setStatus(judgeId);}

    public void clearStatus(String projectId){judgeDao.clearStatus(projectId);}

    public void votedJudge(Integer judgeId){
        judgeDao.votedJudge(judgeId);
    }

    public void deleteJudge(Integer judgeId){judgeDao.deleteJudge(judgeId);}

    public void deleteAllJudge(String projectId){judgeDao.deleteAllJudge(projectId);}
}
